home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / time.h.z / time.h
C/C++ Source or Header  |  1992-04-03  |  4KB  |  142 lines

  1. /*
  2.  * time.h --
  3.  *
  4.  *     Header for BSD time calls (plus some other stuff)
  5.  *
  6.  *
  7.  * Copyright 1990, Silicon Graphics, Inc. 
  8.  * All Rights Reserved.
  9.  *
  10.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  11.  * the contents of this file may not be disclosed to third parties, copied or 
  12.  * duplicated in any form, in whole or in part, without the prior written 
  13.  * permission of Silicon Graphics, Inc.
  14.  *
  15.  * RESTRICTED RIGHTS LEGEND:
  16.  * Use, duplication or disclosure by the Government is subject to restrictions 
  17.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  18.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or 
  19.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 
  20.  * rights reserved under the Copyright Laws of the United States.
  21.  */
  22. /*
  23.  * Copyright (c) 1982 Regents of the University of California.
  24.  * All rights reserved.  The Berkeley software License Agreement
  25.  * specifies the terms and conditions for redistribution.
  26.  *
  27.  *    @(#)time.h    6.4 (Berkeley) 6/24/85
  28.  */
  29.  
  30. /*    time.h    6.1    83/07/29    */
  31. #ident    "$Revision: 3.17 $"
  32.  
  33. #ifndef __SYS_TIME_H__
  34. #define __SYS_TIME_H__
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #ifndef _KERNEL
  41. /* move this #include here so that ALL instances of 'timezone' agree */
  42. #include <time.h>
  43. #endif
  44.  
  45. #ifndef _CLOCK_T_
  46. #define _CLOCK_T_
  47. typedef long    clock_t;    /* Type returned by clock(3C) */
  48. #endif /* !_CLOCK_T_ */
  49.  
  50. /* needed here according to MIPS ABI draft */
  51. #ifndef _TIME_T_
  52. #define _TIME_T_
  53. typedef    long        time_t;        /* <time> type */
  54. #endif /* !_TIME_T_ */
  55.  
  56. /*
  57.  * Structure returned by gettimeofday(2) system call,
  58.  * and used in other calls.
  59.  */
  60. struct timeval {
  61.     long    tv_sec;        /* seconds */
  62.     long    tv_usec;    /* and microseconds */
  63. };
  64.  
  65. /*
  66.  * Higher resolution time information, currently only used in /debug,
  67.  * but defined by MIPS ABI.
  68.  */
  69. typedef struct timestruc {
  70.     time_t    tv_sec;        /* seconds */
  71.     long    tv_nsec;    /* and nanoseconds */
  72. } timestruc_t;
  73.  
  74. struct timezone {
  75.     int    tz_minuteswest;    /* minutes west of Greenwich */
  76.     int    tz_dsttime;    /* type of dst correction */
  77. };
  78. #define    DST_NONE    0    /* not on dst */
  79. #define    DST_USA        1    /* USA style dst */
  80. #define    DST_AUST    2    /* Australian style dst */
  81. #define    DST_WET        3    /* Western European dst */
  82. #define    DST_MET        4    /* Middle European dst */
  83. #define    DST_EET        5    /* Eastern European dst */
  84. #define    DST_CAN        6    /* Canada */
  85.  
  86. /*
  87.  * Operations on timevals.
  88.  *
  89.  * NB: timercmp does not work for >= or <=.
  90.  */
  91. #define    timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
  92. #define    timercmp(tvp, uvp, cmp)    \
  93.     ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  94.      (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  95. #define    timerclear(tvp)        (tvp)->tv_sec = (tvp)->tv_usec = 0
  96.  
  97. /*
  98.  * Names of the interval timers, and structure
  99.  * defining a timer setting.
  100.  */
  101. #define    ITIMER_REAL    0
  102. #define    ITIMER_VIRTUAL    1
  103. #define    ITIMER_PROF    2
  104.  
  105. struct    itimerval {
  106.     struct    timeval it_interval;    /* timer interval */
  107.     struct    timeval it_value;    /* current value */
  108. };
  109.  
  110. #ifndef _KERNEL
  111. extern int gettimeofday(struct timeval *tp,struct timezone *tzp);
  112. extern int settimeofday(struct timeval *tp,struct timezone *tzp);
  113. extern int adjtime(struct timeval *delta, struct timeval *odelta);
  114. extern int getitimer(int, struct itimerval *);
  115. extern int setitimer(int, struct itimerval *, struct itimerval *);
  116. #else
  117. #define    USEC_PER_SEC    1000000        /* number of usecs for 1 second    */
  118.  
  119. /*
  120.  * macro to round usec to sec in time timeval structure.
  121.  * We even go so far as to loop decrementing usec and adding to seconds until
  122.  * usec < sec.
  123.  */
  124. #define    RNDTIMVAL(t) \
  125.     { \
  126.         register struct timeval *tp = (t); \
  127.         \
  128.         while ( tp->tv_usec >= USEC_PER_SEC ) \
  129.         { \
  130.             tp->tv_usec -= USEC_PER_SEC; \
  131.             tp->tv_sec++; \
  132.         } \
  133.     }
  134. #endif
  135.  
  136.  
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140.  
  141. #endif /* __SYS_TIME_H__ */
  142.